let express = require('express')
let app = express()

//创建一个局部中间件
const mw1 = (req,res,next) =>{
    console.log('调用了中间件mw1')
    next()
}

//导入并注册中间件 body-parser
const parser = require('body-parser');
app.use(parser.urlencoded({extended:false}))
app.get('/user/:id',mw1,(req,res)=>{
    console.log('有人请求了user接口')
    // console.log(req.params.id)
    // console.log(req.query)
    // console.log(req)

    console.log(req.body)
    res.send({name:'昂秋丽',age:30})
})

app.use(express.static('./src'))

app.listen('80',()=>{
    // req.get('/user',()=>{
    //     debugger
    //     console.log(req.query)
    // })
    console.log('已经启动一个80端口的服务')

    
})